package com.lzb.compressmaster.adapter;


import android.view.View;
import android.widget.ImageView;

import androidx.annotation.NonNull;

import com.bumptech.glide.Glide;
import com.chad.library.adapter.base.provider.BaseItemProvider;
import com.chad.library.adapter.base.viewholder.BaseViewHolder;
import com.lzb.compressmaster.R;
import com.lzb.compressmaster.basic.ProviderMultiAdapter;
import com.lzb.compressmaster.basic.picselect.SelectMediaEntity;
import com.lzb.compressmaster.utils.TimeUtil;

public class SelVideoAdapter extends ProviderMultiAdapter<SelectMediaEntity> {


    public SelVideoAdapter() {
        addItemProvider(new SelVideoProvider());
    }

    private class SelVideoProvider extends BaseItemProvider<SelectMediaEntity> {
        @Override
        public int getItemViewType() {
            return ProviderMultiAdapter.TYPE_VIEW;
        }

        @Override
        public int getLayoutId() {
            return R.layout.item_sel_video;
        }

        @Override
        public void convert(@NonNull BaseViewHolder baseViewHolder, SelectMediaEntity selectMediaEntity) {
            Glide.with(getContext()).load(selectMediaEntity.getPath())
                    .into((ImageView) baseViewHolder.getView(R.id.ivSelVideoItemImg));
            baseViewHolder.setText(R.id.tvSelVideoItemDuration, TimeUtil.getMmss(selectMediaEntity.getDuration()));
            if (selectMediaEntity.isChecked()) {
                baseViewHolder.setImageResource(R.id.ivSelVideoItemSel, R.drawable.img_sel);
            } else {
                baseViewHolder.setImageResource(R.id.ivSelVideoItemSel, R.drawable.img_not_sel);
            }
        }
    }

}
